home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
OTHER_LA
/
YERK__
/
TOOLBOX_
/
QD1
< prev
next >
Wrap
Text File
|
1986-09-20
|
4KB
|
172 lines
\ qd1 - more QuickDraw objects
\ 12/14/84 cbd Version 1
\ 11/16/85 cdn Added disp: method to Picture & Icon
Decimal
: +pair { x1 y1 x2 y2 -- x1+y1 x2+y2 } x1 x2 + y1 y2 + ;
\ Interface object for QD picture support
:CLASS Picture <Super Object
Handle picHndl
Int resID \ resource ID if it is a resource
Rect DestRect \ destination rectangle for drawing
\ ( l t r b -- ) Open a new pict with given frame
:M OPEN: Put: tempRect 0 abs: tempRect call OpenPicture
Put: picHndl ;M
\ ( -- ) terminate this picture definition
:M CLOSE: call ClosePicture ;M
\ ( resID -- )
:M INIT: put: resID ;M
\ load the picture from a resource file
:M GETNEW: 0 int: resID call GetPicture put: picHndl
ptr: picHndl 2+ get: rect put: destRect ;M
\ ( w h -- ) Set size in pixels of dest rect
:M SIZE: getTop: destRect +Pair putBot: destRect ;M
\ ( x y -- ) Move dest rect to given location
:M GOTO: { x y -- } Size: destRect x y putTop: DestRect
Size: self ;M
\ ( -- ) Draw the picture in destRect
:M DRAW: get: picHndl abs: destRect
call DrawPicture ;M
\ ( x y resID -- ) Combines the actions of init:, getNew:, goto: & draw:
:M DISP: init: self getNew: self goto: self draw: self ;M
\ ( -- ) dispose of picture heap
:M KILL: get: picHndl call KillPicture ;M
;CLASS
\ resource-based Icon
:CLASS Icon <Super Object
Handle theHandle
Int resID
Rect theRect
\ ( resID -- ) set the resource ID
:M INIT: put: resID ;M
\ load the icon from a resource file
:M GETNEW: 0 int: resID call GetIcon put: theHandle ;M
\ ( x y -- ) move topLeft corner to x,y
:M GOTO: { x y -- } x y x 32 + y 32 + put: theRect ;M
\ draw the icon at current location
:M DRAW: abs: theRect get: theHandle call PlotIcon ;M
\ ( x y resID -- ) Combines the actions of init:, getNew:, goto: & draw:
:M DISP: init: self getNew: self goto: self draw: self ;M
;CLASS
\ define the quickDraw bitmap object
:CLASS qdBitMap <Super Object
Var BaseAddr
Int RowBytes
Rect BndsRect
\ ( addr n l t r b -- )
:M PUT: Put: bndsRect Put: RowBytes
Put: BaseAddr ;M
;CLASS
\ rounded rectangle
:CLASS RndRect <Super Rect
Point ovalSize \ size in pixels of ovals at corners
\ ( w h -- ) set width, height of corners
:M INIT: put: ovalSize ;M
\ ( -- )
:M DRAW: (abs) int: ovalSize call FrameRoundRect ;M
:M PRINT: Draw: Self ;M
:M CLEAR: (abs) int: ovalSIze call EraseRoundRect ;M
\ ( ^patObj -- ) Fill rect with pattern )
:M FILL: { pat -- }
(abs) int: ovalSize pat +base call FillRoundRect ;M
\ ( -- x y )
:M CENTER: { \ x y -- } Size: Self 2/ -> y 2/ -> x
GetX: TopL x + getY: topL y + ;M
\ ( -- )
:M INVERT: (abs) int: ovalSize call InverRoundRect ;M
\ ( -- )
:M PAINT: (abs) int: ovalSize call PaintRoundRect ;M
;CLASS
\ QuickDraw ovals - data is same as a Rect
:CLASS Oval <Super Rect
\ ( -- )
:M DRAW: (abs) call FrameOval ;M
\ ( -- )
:M CLEAR: (abs) call EraseOval ;M
\ ( -- )
:M PAINT: (abs) call PaintOval ;M
:M FILL: { pat -- } (abs) pat +base call FillOval ;M
:M INVERT: (abs) call InvertOval ;M
;CLASS
\ Variable-length image object for bit images
\ E.G., an Icon would have 32 cells, rowbytes=4
:CLASS Image <Super Array
Var BaseAddr
Int RowBytes \ Source bitMap
Rect bndsRect
Var DestBits \ addr of destination bit image
Int Mode
Rect Destrect \ Destination rect for CopyBits
\ ( -- ) Set the source, destination bitmap ptrs
:M GETPORT: Abs: DestBits call GetPort 2 +: DestBits
0 ^elem: self +base Put: baseAddr ;M
\ ( mode rowBytes topX topY -- )
:M INIT: { themode rBytes topX topY -- } themode Put: mode
rBytes Put: RowBytes topX topY PutTop: bndsRect
rBytes 8 * topX + \ # of bits in a row + topX
limit: self width: self * rBytes / topY + \ # of rows + topy
PutBot: bndsRect
GetPort: Self ;M
\ ( x y -- ) Move location without drawing
:M GOTO: { xloc yloc -- } xloc yloc Puttop: DestRect
size: bndsRect xloc yloc +Pair PutBot: destRect ;M
\ ( -- ) Draw the image at its current location
:M DRAW: (abs) Get: DestBits Abs: bndsRect Abs: DestRect
Int: Mode 0 call CopyBits ;M
\ ( x y -- ) Goto a location and draw the image
:M MOVETO: Goto: Self Draw: Self ;M
:M CLASSINIT: srcXor 2 0 0 Init: Self 0 0 Goto: self ;M
;CLASS